#include <bits/stdc++.h>
using namespace std;

const int N = 100010;

int d[N], v[N], a[N], p[N];
int nxt[N], vis[N], flag[N];

bool cmp(pair<int, int>a, pair<int, int> b) {
	return a.second < b.second;
}
//wo jin li le
//sui bai!you rong...
//ti gao zu yi deng
//zhu ding bu shi jin nian...
//bu gua fen de hua shi 100+40+25=165
//ru guo zai duo yi dian de hua shi 100+80+25=205
//bu zhi dao 1= gou bu gou....
//bu lun ru he
//zhe bo 7 ji gou ying gai shi you le
//wo dou mei xiang dao wo neng zuo zhe me duo fen ne...(jin guan ti mu hen jian dan......)
//jia you ba!shao nian!
int main() {
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	int T;
	scanf("%d", &T);
	while(T--) {
		memset(nxt, 0, sizeof(nxt));
		memset(vis, 0, sizeof(vis));
		memset(flag, 0, sizeof(flag));
		int n, m, L, V;
		scanf("%d%d%d%d", &n, &m, &L, &V);
		for (int i = 1; i <= n; i++) {
			scanf("%d%d%d", &d[i], &v[i], &a[i]);
		}
		for (int i = 1; i <= m; i++) {
			scanf("%d", &p[i]);
		}
		for (int i = 1; i <= n; i++) {
			nxt[i] = lower_bound(p + 1, p + m + 1, d[i]) - p;
		}
		int cnt = 0;
		for (int i = 1; i <= n; i++) {
			int x;
			if (a[i] >= 0) x = p[m] - d[i];
			else x = p[nxt[i]] - d[i];
			if (x >= 0 && 2 * a[i] * x + v[i] * v[i] > V * V) {
				flag[i] = 1;
				cnt++;
			}
		}
		int flag1 = 1;
		for (int i = 1; i <= n; i++) {
			if (a[i] < 0) flag1 = 0;
		}
		if (flag1) {
			printf("%d ", cnt);
			if (cnt == 0) printf("%d\n", m);
			else printf("%d\n", m - 1);
			continue;
		}
		vector<pair<int, int> > va;
		for (int i = 1; i <= n; i++) {
			if (flag[i] == 1 && a[i] < 0) {
                int pos = 0;
				for (int j = nxt[i]; j <= m; j++) {
					int x = p[j] - d[i];
					if (x >= 0 && 2 * a[i] * x + v[i] * v[i] > V * V) {
						if (j == m) pos = j, va.push_back({nxt[i], pos});
						else {
							x = p[j + 1] - d[i];
							if (x >= 0 && 2 * a[i] * x + v[i] * v[i] <= V * V) {
								pos = j;
								va.push_back({nxt[i], pos});
								break;
							}
						}
					}
				}
				//int flag2 = 0;
               // for (int j = nxt[i]; j <= pos; j++) {
               //     if (vis[j] == 1) {
               //         flag2 = 1;
               //         break;
               //     }

			}
		}
		sort(va.begin(), va.end(), cmp);
		for (int i = 0; i < va.size(); i++) {
			int flag2 = 0;
			for (int j = va[i].first; j <= va[i].second; j++) {
				if (vis[j] == 1) {
					flag2 = 1;
					break;
				}
			}
			if (!flag2) vis[va[i].second] = 1;
		}
		for (int i = 1; i <= n; i++) {
			int flag4 = 0;
			for (int j = nxt[i]; j <= m; j++) {
				if (vis[j] == 1) {
					flag4 = 1;
					break;
				}
			}
			if (!flag4) {
				vis[m] = 1;
				break;
			}
		}
		int ans = 0;
		for (int i = 1; i <= m; i++) {
            if (vis[i] == 0) ans++;
		}
		printf("%d %d\n",cnt, ans);
//		vector<pair<int, int> > va;
//		for (int i = 1; i <= n; i++) {
//			if (flag[i] == 1 && a[i] >= 0) vis[m] = 1;
//			else if (flag[i] == 1) {
//				for (int j = nxt[i]; j <= m; j++) {
//					int x = p[j] - d[i];
//					if (x >= 0 && 2 * a[i] * x + v[i] * v[i] > V * V) {
//						if (j == m) va.push_back({d[i], p[j]});
//						else {
//							x = p[j + 1] - d[i];
//							if (x >= 0 && 2 * a[i] * x + v[i] * v[i] <= V * V) {
//								va.push_back({d[i], p[j]});
//								break;
//							}
//						}
//					}
//				}
//			}
//		}
//		for (int i = 0; i < va.size(); i++) {
//			cout << va[i].first << " " << va[i].second << endl;
//		}
//		sort(va.begin(), va.end(), cmp);
//		int R = va[0].second;
//		vis[R] = 1;
//		for (int i = 1; i < va.size(); i++) {
//			if (va[i].first > R) {
//				R = va[i].second;
//				vis[R] = 1;
//			}
//		}
//		int ans = 0;
//		for (int i = 1; i <= m; i++) {
//			ans += vis[i];
//		}
//		printf("%d %d\n", cnt, m - ans);
	}
	return 0;
}
//wo zi heng dao xiang tian xiao,qu liu gan dan liang qian kun
//my name:__O_w_O__
//zhan guo:2024CSP-S:100+80+25
//wo bu yi deng shui ren yi deng????
//lan gou ,wo laile!
//zhan guo :150 duo hang de dai ma
//li jing 3 ge xiao shi de tiao shi
//chu le 15 fen zhong xie A,10 fen zhong xie 25pts de C
//dao 18:00 zheng,zuo chu le 80 fen
//zhe ti yong le wo zheng zheng 3 xiao shi 15 fen zhong
//shuang le, wo gan jue wo cha bu duo ye xiang chu lai zheng jie le
//bu guo mei shi jian dan le
//bu guo......zhe ye jiu zu gou le!
